# =============================================================================
if (OS_WINDOWS)
  set(WORKFLOW_ROOT ${COMMON_THIRD_LIB}/workflow)

  find_library(WORKFLOW_LIBRARY_DEBUG
    NAMES workflow
    PATHS ${WORKFLOW_ROOT}/dist/Debug
    PATH_SUFFIXES "lib" "lib32" "lib64"
    REQUIRED)
  find_library(WORKFLOW_LIBRARY_RELEASE
    NAMES workflow
    PATHS ${WORKFLOW_ROOT}/dist/Release
    PATH_SUFFIXES "lib" "lib32" "lib64"
    REQUIRED)
elseif(OS_LINUX)
  find_package(workflow REQUIRED CONFIG HINTS ..)
endif()

macro(use_workflow ag_project_name)
  target_compile_definitions(${ag_project_name} PRIVATE USE_LIB_WORKFLOW)

  if (OS_WINDOWS)
    target_include_directories(${ag_project_name} PRIVATE ${WORKFLOW_ROOT}/dist/$<CONFIG>/include)
    target_link_libraries(${ag_project_name} PRIVATE 
      debug ${WORKFLOW_LIBRARY_DEBUG}
      optimized ${WORKFLOW_LIBRARY_RELEASE})
  elseif(OS_LINUX)
    target_include_directories(${ag_project_name} PRIVATE ${WORKFLOW_INCLUDE_DIR})
    target_link_directories(${ag_project_name} PRIVATE ${WORKFLOW_LIB_DIR})
    target_link_libraries(${ag_project_name} PRIVATE workflow OpenSSL::SSL OpenSSL::Crypto)
  endif()
endmacro(use_workflow)